package spring.cloud.tasks.client.item_task_processor;

import lombok.Getter;
import lombok.Setter;

import java.util.List;


public class Task {

    @Setter
    @Getter
    private String taskId;
    @Setter
    @Getter
    private String taskName;


    @Setter
    @Getter
    private String cronExpressionString;
    @Setter
    @Getter
    private String processorType = "sleep";//sleep or wait
    @Setter
    @Getter
    private String taskParameter;
    @Setter
    @Getter
    private String[] taskItems;

    public static String status_pause = "pause";
    public static String status_run_or_recover = "run_or_recover";
    /**
     * pause,runOrRecover
     */
    @Setter
    @Getter
    private String status = status_run_or_recover;
    //@Setter
    @Getter
    private long heartBeatRate = 5 * 1000;
    //@Setter
    @Getter
    private long judgeDeadInterval = heartBeatRate * 12;
    @Setter
    @Getter
    private int sleepTimeWhenNoData = 1000;
    @Setter
    @Getter
    private int fetchNum = 1000;
    @Setter
    @Getter
    private int maxExecuteNum = 1;

    //调度器信息
    @Setter
    @Getter
    private int totalprocessorCount;
    @Setter
    @Getter
    private int threadCountPerTaskProcessor = 5;
    //如果有该标记 代表现在只是单机处理,那么调度器在真正创建处理的时候最多不能超过5个。
    @Setter
    @Getter
    private boolean onlyOneWorkerDealWithTask = false;
    @Setter
    @Getter
    private int threadCountPerProcessorWhenOnlyOneWorkerDealWithTask = 2;//避免CPU处理过快
    @Setter
    @Getter
    private List<String> ipList;

    public int getMinThreadCountPerProcessor() {
        return onlyOneWorkerDealWithTask ? threadCountPerProcessorWhenOnlyOneWorkerDealWithTask : threadCountPerTaskProcessor;
    }

    //
    @Setter
    @Getter
    private int taskItemVersion = 0;
    @Setter
    @Getter
    private int taskItemInvalidTime = 1000 * 60 * 15;//15分钟失效
}
